import away3d.audio.*;
import away3d.cameras.*;
import away3d.cameras.lenses.*;
import away3d.containers.*;
import away3d.core.base.*;
import away3d.core.clip.*;
import away3d.core.math.*;
import away3d.events.*;
import away3d.lights.*;
import away3d.loaders.*;
import away3d.materials.*;
import away3d.primitives.*;
import away3d.sprites.*;

import com.powerfl.frm.taf.*;

import flash.display.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;

final public function addView( $key:String, $isOrthogonal:Boolean = false, ...$param ):void{
	var param:TAFparam;
	param = $paramGet( $param );
	orderAddByKeyCheck( $key, param, function():void{
		var scene:Scene3D, camera:*, view:View3D;
		scene = new Scene3D;
		if( $isOrthogonal ){
			camera = new Camera3D( {lens:new OrthogonalLens, focus:10, z:-900} );
		}else{
			camera = new TargetCamera3D( {z:-900} );
			addTree( '@DATA', $key+'@target', 'target', camera.target, null );
		}
		view = new View3D( {scene:scene, camera:camera} );
		addTree( '@STAGE', $key, 'stage', view, param );
		addTree( '@DATA', $key+'@scene', 'scene', scene, null );
		addTree( '@DATA', $key+'@camera', 'camera', camera, null );
		
		resizeView( $key );
	} );
}
final public function addEffectView( $key:String, $maskKey:String, $blend:String, ...$param ):void{
	var param:TAFparam;
	param = $paramGet( $param );
	orderAddByKeyCheck( $key, param, function():void{
		var b:Bitmap;
		b = bitmap( bitmapDataGet( $maskKey ) );
		b.blendMode = $blend;
		addTree( '@STAGE', $key, 'stage', b, param );
	} );
}
final public function addBlitView( $key:String, ...$param ):void{
	var param:TAFparam;
	param = $paramGet( $param );
	orderAddByKeyCheck( $key, param, function():void{
		var view:TAFbitmapBlit;
		view = new TAFbitmapBlit;
		param.applyVar( view );
		view.init();
		addTree( '@STAGE', $key, 'stage', view, param );
		flowAdd_( $key + '@down', view.down );
		flowAdd_( $key + '@up', view.up );
		bindRunner( [$key + '@down'], SELF._mouseDown );
		var temp:*=SELF._mouseDown;
		bindRunner( [$key + '@up'], SELF._mouseUp );
	} );
}

final public function addBlit( $parent:String, $key:String, ...$param ):void{
	var param:TAFparam;
	param = $paramGet( $param );
	orderAddByKeyCheck( $key, param, function():void{
		addTree( $parent, $key, 'bitmapChild', poolPullTAFbitmapBlitChild( param ), param );
	} );
}